// C参考代码

#include <bits/stdc++.h>
const int MAXN = 1e6 + 5;
int cnt[MAXN], b[MAXN], res;
int n, q;

int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    b[i] = i;
    cnt[i] = 1;
  }
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int p, h;
      scanf("%d%d", &p, &h);
      // 将鸽子从 b[p] -> h--cnt[b[p]];
      if (cnt[b[p]] == 1)
        --res;
      ++cnt[h];
      if (cnt[h] == 2)
        ++res;
      b[p] = h;
    } else {
      printf("%d\n", res);
    }
  }
  return 0;
}
